package com.mall.server.repository;

import com.mall.server.model.VerificationCode;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface VerificationCodeRepository extends JpaRepository<VerificationCode, Long> {
    
    @Query("SELECT v FROM VerificationCode v WHERE v.phone = ?1 AND v.used = false ORDER BY v.createdAt DESC")
    Optional<VerificationCode> findLatestByPhone(String phone);
} 